package com.hjb.service.impl.task;

import com.hjb.service.domain.recharge.SiteUserRecharge;
import com.hjb.service.domain.recharge.SiteUserRechargeExample1;
import com.hjb.service.domain.withdraw.PayCashWithdraw;
import com.hjb.service.domain.withdraw.PayCashWithdrawExample;
import com.hjb.service.gateway.baofoo.domain.request.TransReqBF0040002;
import com.hjb.service.mapper.PayCashWithdrawMapper;
import com.hjb.service.mapper.SiteUserRechargeMapper;
import com.hjb.service.recharge.RechargeService;
import com.hjb.service.task.WithDrawQueryService;
import com.hjb.service.withdraw.FYWithDrawService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by gy on 2017/7/29.
 * 宝付代付查询
 */
@Service
public class WithDrawQueryServiceImpl implements WithDrawQueryService {

	private Logger log = LoggerFactory.getLogger(getClass());
	@Autowired
	private PayCashWithdrawMapper payCashWithdrawMapper;
	@Autowired
	private FYWithDrawService fyWithDrawService;

	@Override
	public void withDrawQuery() throws RuntimeException{
		//try {
			//1.获取提现记录
			PayCashWithdrawExample example = new PayCashWithdrawExample();
			example.createCriteria().andStatusEqualTo(2);//等待回调
			List<PayCashWithdraw> payCashWithdrawList = payCashWithdrawMapper.selectByExample(example);
			if (payCashWithdrawList == null || payCashWithdrawList.size() ==0){
				log.info("未查到等待回调的提现记录");
				return;
			}
			//2.调取三方查询
			for (PayCashWithdraw payCashWithdraw:payCashWithdrawList){
				fyWithDrawService.withdrawQuery(payCashWithdraw);
			}
		/*}catch (Exception e){
			log.info("提现查询失败"+e);
		}*/
	}
}
